home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
prog_c
/
malloc15.zip
/
TEST.C
< prev
Wrap
Text File
|
1996-04-17
|
2KB
|
86 lines
#include <stdio.h>
#include <malloc.h>
#include "mem.h"
main()
{
char *foo = "hello";
char *s, *t;
printf("hello, world\n");
free(foo);
s = malloc(10);
strcpy(s, foo);
s = realloc(s, 6);
puts(s);
s = malloc(10);
t = malloc(10);
memcpy(s, t, 11);
s = malloc(20);
memcpy(s, t, 11);
s = strdup("foo");
memcpy(s, t, 11);
s = realloc(s, 6);
memcpy(s, t, 21);
sprintf(s, "1234567890 %s ", "hello");
free(s);
free(t);
return(0);
}
From hornen@hlbjoan.agw.bt.co.uk Wed Apr 17 18:07:44 1996
Received: from punt2.demon.co.uk by smsltd.demon.co.uk with SMTP
id AA12820 ; Wed, 17 Apr 96 18:07:40 BST
Received: from punt-2.mail.demon.net by mailstore for njh@smsltd.demon.co.uk
id 829733659:22996:2; Wed, 17 Apr 96 10:34:19 BST
Received: from mailhub.axion.bt.co.uk ([132.146.5.4]) by punt-2.mail.demon.net
id aa22677; 17 Apr 96 10:33 +0100
Received: from catullus.agw.bt.co.uk by mailhub.axion.bt.co.uk with SMTP (PP); Wed, 17 Apr 1996 10:31:49 +0100
Received: from isdgate.agw.bt.co.uk (isdgate.agw.bt.co.uk [147.150.41.229]) by catullus.agw.bt.co.uk (8.6.12/8.6.11) with SMTP
id KAA25209 for <njh@smsltd.demon.co.uk>; Wed, 17 Apr 1996 10:35:01 +0100
Received: by isdgate.agw.bt.co.uk with Microsoft Mail id <3174C7E2@isdgate.agw.bt.co.uk>; Wed, 17 Apr 96 10:28:50 GMT
From: "Horne, Nigel" <hornen@hlbjoan.agw.bt.co.uk>
To: NJH <njh@smsltd.demon.co.uk>
Subject: TEST.C
Date: Wed, 17 Apr 96 10:23:00 GMT
Message-ID: <3174C7E2@isdgate.agw.bt.co.uk>
Encoding: 3 TEXT, 1 TEXT
X-Mailer: Microsoft Mail V3.0
X-MS-Attachment: TEST.C 595 04-17-1996 09:46
Status: R
[[ TEST.C : 2373 in TEST.C ]]
#include <stdio.h>
#include <malloc.h>
#include "mem.h"
main()
{
char *foo = "hello";
char *s, *t;
printf("hello, world\n");
free(foo);
s = malloc(10);
strcpy(s, foo);
s = realloc(s, 6);
puts(s);
s = malloc(10);
t = malloc(10);
memcpy(s, t, 11);
s = malloc(20);
memcpy(s, t, 11);
s = strdup("foo");
memcpy(s, t, 11);
s = realloc(s, 6);
memcpy(s, t, 21);
sprintf(s, "1234567890 %s ", "hello");
free(s);
free(t);
return(0);
}